<?php

namespace app\api\controller;

use app\api\model\Merchant as MerchantModel;
use app\api\model\UserTwo as UserModel;
use think\facade\Session;

class Adduser extends Controller
{
    /* @var \app\api\model\User $model */
    private $user;

    /**
     * 构造方法
     * @throws \app\common\exception\BaseException
     * @throws \think\exception\DbException
     */
    public function initialize()
    {
        $this->user = $this->getUser();//商户总信息
    }

    /**
    添加装修公司商家
     **/
    public  function  merchantAdd(){
        $info = $this->request->post();
        if(empty($info['merchant_name'])||empty($info['merchant_set'])||empty($info['daimabianma'])||empty($info['phone'])||empty($info['address'])||empty($info['shenfz'])||empty($info['images1'])||empty($info['images2'])||empty($info['images3'])||empty($info['images4'])){
            return $this->renderError('1009','缺少参数',$data = []);
        }
        $model = new MerchantModel();
        $asd = $model->zhuangxiuAdd($this->user, $info);
        if ($asd == '1000') {
            $model2 = new UserModel();
            $statalist = $model2->leixinglist($this->user['user_id']);
            return $this->renderSuccess('1000','添加成功',$statalist);
        }else{
            return $this->renderError($asd,'添加失败',$data = []);
        }

    }

    /**
    添加商店商家
     **/
    public  function  renovationAdd(){
        $info = $this->request->post();
        if(empty($info['merchant_name'])||empty($info['merchant_set'])||empty($info['phone'])||empty($info['address'])||empty($info['shenfz'])||empty($info['images1'])||empty($info['images2'])||empty($info['images3'])||empty($info['images4'])){
            return $this->renderError('1009','缺少参数',$data = []);
        }
        $model = new MerchantModel();
        $asd = $model->renovationAdd($this->user, $info);
        if ($asd == '1000') {
            $model2 = new UserModel();
            $statalist = $model2->leixinglist($this->user['user_id']);
            return $this->renderSuccess('1000','添加成功',$statalist);
        }else{
            return $this->renderError($asd,'添加失败',$data = []);
        }
    }

    /**
    添加设计师商家
     **/
    public  function  designerAdd(){
        $info = $this->request->post();
        if(empty($info['merchant_name'])||empty($info['phone'])||empty($info['shenfz'])||empty($info['images1'])||empty($info['images2'])||empty($info['images3'])||empty($info['images4'])){
            return $this->renderError('1009','缺少参数',$data = []);
        }
        $model = new MerchantModel();
        $asd = $model->designerAdd($this->user, $info);
        if ($asd == '1000') {
            $model2 = new UserModel();
            $statalist = $model2->leixinglist($this->user['user_id']);
            return $this->renderSuccess('1000','添加成功',$statalist);
        }else{
            return $this->renderError($asd,'添加失败',$data = []);
        }
    }

}
